<template>
  <div class="particulars">
    <v-detail
      :detailData="inputData"
      :inputConfig="inputConfig"
      :rules="rules"
      @pop="setdata"
      ref="input"
    ></v-detail>
  </div>
</template>

<script>
import detail from "commons/Detail";
import baseMixin from "@/mixins/BaseMixin";

export default {
  name: "particulars",
  mixins: [baseMixin],
  props: {
    inputData: {
      type: Object
    }
  },
  data () {
    return {
      inputConfig: [
        [
          {
            type: "select",
            label: this.$t('bill.orderType'),
            props: "ordertype",
            options: this.getOptions('querycodeLkup/ORDERTYPE'),
            disabled: !this.$store.state.newFlag
          },
          {
            type: "input",
            label: this.$t('bill.serial'),
            props: "sequence",
          },
          {
            type: "select",
            label: this.$t('config.freezeDesc'),
            props: "statuscode",
            options: this.getOptions('queryInventoryholdcodeDropDown'),
            disabled: !this.$store.state.newFlag
          }
        ]
      ],
      rules: {
        ordertype: [
          { required: true, message: this.$selectPlease('bill.orderType'), trigger: 'blur' },
        ],
        sequence: [
          { required: true, validator: this.sequence, trigger: 'blur' },
        ],
        statuscode: [
          { required: true, message: this.$selectPlease('config.freezeDesc'), trigger: 'blur' },
        ],
      },
    }
  },
  computed: {},
  methods: {
    sequence (rule, value, callback) {
      if (value === '') {
        this.$message.error(this.$inputPlease('bill.serial'));
        callback(new Error());
      } else {
        var re = /^[0-9]*$/;
        let te = value;
        let flag = re.test(te)
        if (flag) {
          if (value < 0) {
            this.$message.error(this.$t('app.inputGreaterZeroNumberPlease'))
            this.inputData[rule.field] = ""
            callback(new Error());
          } else {
            callback();
          }
        } else {
          this.$message.error(this.$t('app.inputGreaterZeroNumberPlease'))
          this.inputData[rule.field] = ""
          callback(new Error());
        }
      }
    },
    setdata (data, id, close) {
      this.detailData.toloc = data.loc;
      close(false);
    }
  },
  mounted () {
  },
  components: {
    "v-detail": detail,
  },

}
</script>

<style scoped>
</style>
